const express = require('express')
const router = express.Router()
const connection = require('.././mysql')

router.post('/adminLogin', (req, res) =>{
    const {username, password} = req.body.params.info    
    
    const sql = 'select * from admins where a_name =? and a_pwd =?'
    connection.query(sql, [username, password], (err, result) => {
        if(err){
            console.log(err);
            res.send({status: 500, msg: '服务器内部错误'})
        }

        if(result.length > 0){
            res.send({
                status: 200,
                msg: '登录成功',
            })
        }else{
            res.send({
                status: 400,
                msg: '用户名或密码错误'
            })
        }
        
    })
    
})


module.exports = router;